VB6 and Frames, Buttons, Checkboxes, Radiobutton Controls

As of SftTabs/OCX 6.52 we have changed the internal handling of Frame, Button, RadioButton and Checkbox controls that are placed on a tab control. VB6 doesn't support the new look of all these controls, as introduced with recent Windows versions. VB6 does not know how to handle Windows Themes.

Turning Windows Themes on or off is accomplished by right-clicking on the desktop and selecting "Personalize", or through Control Panel.

This used to place some limitations on VB6 applications. While earlier versions of SftTabs/OCX would handle Windows Themes, with version 6.52 and above additional support has been added so frames, buttons, radio buttons and checkboxes can be handled properly, whether Windows Themes are used and even when users switch between themes. Or worse, turn them on/off while your application is running.

The main problem is the Appearance property of the these controls. You can choose between Flat and 3D appearance. When selecting the 3D appearance and Windows Themes are active, these controls will not look correct. On the other hand, when selecting Flat, they will look correct with Windows Themes active, but will look incorrect when themes are off. So, we have devised this simple VB6 code that updates the Appearance properties of all controls on a form:

Private Sub UpdateControls(ByVal ctrls As Object, ByVal theme As Boolean)
    Dim c As Control
    For Each c In ctrls
        On Error Resume Next
        If theme Then
            c.Appearance = 0 ' Flat, when themes are active
        Else
            c.Appearance = 1 ' 3D, let VB handle this when themes are not active
        End If
        On Error GoTo 0
    Next
End Sub

You would call the UpdateControls method in the Form_Load event of each form, where you want to update the Appearance property.

Private Sub Form_Load()
    UpdateControls Me.Controls, SftTabs1.ThemesActive

    '... other code here
End Sub

In this example, SftTabs1 is a SftTabs/OCX control on the form. The ThemesActive property is an undocumented property, which returns whether Windows Themes are active. The SftTabs/OCX control (i.e., SftTabs1) MUST have the UseThemes property set to True. Otherwise, the ThemesActive property will always be False.

Once you add this code, the controls will be initialized correctly whenever your form is loaded, based on the current Windows Themes. The only thing that remains is to detect when Windows Themes are turned on or off, so the UpdateControls method can be called.

SftTabs/OCX 6.52 (and newer) implements an undocumented ThemeChanged event, which notifies the application that the Windows Themes were turned on or off system-wide. You can handle this event for each form with a SftTabs controls where you want to update the Appearance property as follows:

Private Sub SftTabs1_ThemeChanged()
    UpdateControls Me.Controls, SftTabs1.ThemesActive
End Sub

Please note that the rendering of the frames, buttons radio buttons, check boxes or any other controls is NOT implemented or changed by SftTabs, whether these controls are located on the tab control or not. It is still the original VB6 rendering in effect (or Windows rendering the controls in the case of Windows Themes). SftTabs/OCX doesn't enhance or change the rendering in any way. This means that we aren't able to "fix" controls that don't look correct when Windows Themes are active. However, in general, controls should look identical when placed on a tab page or outside the tab control.

For the above sample code, you must have at least SftTabs/OCX 6.52 installed - Older versions do not provide the new ThemeChanged event or the ThemesActive property.